<template>
<!-- <MyHeader/> -->
    <header>
        <h2>vue云音乐</h2>
        <div class="search"  >
            <router-link to="/SearchSongs"> 
            <input type="text"
            class="inputsearch"
             placeholder="请输入歌手、歌曲等"
           v-model="search"
           @keyup.enter="getsearch()"
            >
            </router-link>
           
             
            <div class="iconsearch" @click.stop="getsearch"><router-link to="/SearchSongs">  </router-link></div>
           
         </div>
        
        <ul>
         <li><router-link to="/">首页</router-link> </li>
            <li><router-link to="/SearchSongs">发现音乐</router-link></li>
         
            <li><router-link to="/MyRadio">主播电台</router-link></li>
            <li><router-link to="/">我的</router-link></li>

        </ul>
         
    </header>
</template>

<script>
// import axios from 'axios';
// import  SearchSongs from "./SearchSongs"
export default {
    name:"MyHeader",
    // components:{SearchSongs},
  data() {
          return {
          search:"",
          searchlist: [],  
        }
  },
  methods:{
      getsearch(){
        //   console.log(this.search);
          this.$store.commit('mgetsearch', this.search);
          this.$store.dispatch('agetsearch');
         /**  var that=this;
        // type: 搜索类型；默认为 1 即单曲 , 取值意义 : 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频, 1018:综合
         var va=document.querySelector(".inputsearch");
         var s=va.value;
        //  this.$store.dispatch("agetsearch",s);
        //   console.log(s);
         axios.get("http://localhost:3000/search?keywords="+s)
       .then(function(res){
        //    console.log(11111111111);
        //    console.log(s);
        //    console.log(res);
         console.log(res.data.result.songs);     //data.result.songs
         that.searchlist=res.data.result.songs;
        //    that.$store.state.search=res
       },
       function(erro){
            console.log(erro);
       });*/
    // this.$store.dispatch("agetsearch");
     },
      
  },
 

}
</script>

<style>
 header {
            width: 100%;
            height: 80px;
            background-color: rgba(0, 0, 0, .3);
            text-align: center;
            line-height: 80px;
            padding-left: 100px;
            padding-right: 100px;
        }
        
        header h2 {
            font-family: '华文彩云';
            color: rgb(0, 255, 64);
            font-size: 35px;
            float: left;
            text-shadow: 0px 0px 0px #e2d83c, 1px 1px 0px #e2d83c, 2px 2px 0px #e2d83c, 3px 3px 0px #e2d83c, 4px 4px 0px #e2d83c, 5px 5px 0px #e2d83c;
        }
        
        header .search {
            width: 300px;
            height: 50px;
            float: left;
            position: relative;
            top: 15px;
            margin-left: 100px;
            border-radius: 25px;
            overflow: hidden;
         
        }
        
        header .search input {
            position: absolute;
            width: 300px;
            height: 50px;
            top: 0;
            left: 0;
            outline: none;
            padding-left: 20px;
            font-size: 20px;
        }
        
        header .search .iconsearch  { 
            font-family: 'icomoon';
            font-size:20px;
            position: absolute;
            top:5px;
            right: 30px;
            line-height: 50px;
        }
        
        header ul {
            float: left;
            padding-left: 100px;
        }
        
        header ul li {
            font-size: 20px;
            float: left;
            margin-right: 100px;
        }
</style>